package com.example.weblending.domain.statistics;

import com.example.weblending.vo.AnalyzeColumn;
import com.example.weblending.vo.CsvInputColumn;

public class Installment extends StatisticsBase{

    @Override
    public void init() {
        this.field.add(new StatisticsField("低于200"));
        this.field.add(new StatisticsField("200至400"));
        this.field.add(new StatisticsField("400至600"));
        this.field.add(new StatisticsField("600至800"));
        this.field.add(new StatisticsField("800至1000"));
        this.field.add(new StatisticsField("1000至1200"));
        this.field.add(new StatisticsField("1200至1400"));
        this.field.add(new StatisticsField("大于1400"));
        this.reverse=true;
    }

    @Override
    public void insert(AnalyzeColumn cleanColumn) {
        set(cleanColumn.getInstallment(),cleanColumn.getIs(),cleanColumn);
    }

    @Override
    public void set(float num, float percent, CsvInputColumn column) {
        int index=0;
        if (num>1400){
            this.add(8,percent);
            index=8;
        }
        else if (num>1200){
            this.add(7,percent);
            index=7;
        }
        else if (num>1000){
            this.add(6,percent);
            index=6;
        }
        else if (num>800){
            this.add(5,percent);
            index=5;
        }
        else if (num>600){
            this.add(4,percent);
            index=4;
        }
        else if (num>400){
            this.add(3,percent);
            index=3;
        }
        else if (num>200){
            this.add(2,percent);
            index=2;
        }
        else{
            this.add(1,percent);
            index=1;
        }
        if(this.reverse){
            index = field.size()-index+1;
        }
        column.setInstallment(index);
    }
}
